export const formatDate = (datetime) => {
  const year = datetime.getFullYear()
  const month = datetime.getMonth() + 1 < 10 ? '0' + (datetime.getMonth() + 1) : datetime.getMonth() + 1
  const date = datetime.getDate() < 10 ? '0' + datetime.getDate() : datetime.getDate()
  const h = datetime.getHours() < 10 ? '0' + datetime.getHours() : datetime.getHours()
  const m = datetime.getMinutes() < 10 ? '0' + datetime.getMinutes() : datetime.getMinutes()
  const s = datetime.getSeconds() < 10 ? '0' + datetime.getSeconds() : datetime.getSeconds()

  return `${year}-${month}-${date} ${h}:${m}:${s}`
}
// 获取过去daysNumber天的开始结束时间  例如 过去一天传1   过去7天传7
export const getPastDays = (daysNumber) => {
  var currentTime = new Date()
  var startTime = currentTime.setTime(currentTime.getTime() - daysNumber * 24 * 60 * 60 * 1000)

  return [
    startTime,
    new Date()
  ]
}
// 获取过去hoursNumber小时的开始结束时间  例如 过去一小时传1   过去7小时传7
export const getPastHours = (hoursNumber) => {
  var currentTime = new Date()
  var startTime = currentTime.setTime(currentTime.getTime() - hoursNumber * 60 * 60 * 1000)

  return [
    startTime,
    new Date()
  ]
}